<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>等级修改</title>
    <link  href="../../css/mycss.css" rel="stylesheet" type="text/css"/>
    <script src="../../js/jquery.js"></script>
    <script src="../../js/common.js"></script>
    <script>
        window.onload=function(){
            //获取地址栏的参数id
            let id=obj.getValue2(location.search,"id");
            //向后端发送请求得到数据，装入表单控件中  {键:值}
            $.post(url+"sal/one",{id:id},function(data){
                //元素属性选择器
                $("input[name=grade]").val(data.grade);
                $("input[name=losal]").val(data.losal);
                $("input[name=hisal]").val(data.hisal);
            },"json")
        }
        function tijiao(){
          //向后端发送请求，传递数据，进行回调处理
            //序列化:losal=10&hisal=20
            //data为插入方法的返回值:1 0 -1 ""  1\r\n
            $.get(url+"sal/update",$("form").serialize(),function (data){
                if (data==1){
                    alert("修改成功");
                    //页面跳转
                    location.href="sallist.html";
                }else{
                    alert("修改失败");
                }

            });
            //阻止表单提交
            return false;
        }
    </script>
</head>
<body>
<!--  默认为get请求，action为当前页-->
    <form onsubmit="return tijiao()">
        <table>
            <tr>
                <td>等级编号</td>
                <td>
<!--                    等级编号可设置为hidden或readonly-->
                    <input type="text" name="grade" hidden></td>
            </tr>
            <tr>
                <td>最低工资</td>
                <td><input type="text" name="losal"></td>
            </tr>
            <tr>
                <td>最高工资</td>
                <td><input type="text" name="hisal"></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="submit" value="提交">
                    <input type="reset" value="重置">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>